﻿USE [master]
IF NOT EXISTS(SELECT * FROM [master].[dbo].[syslogins] WHERE loginname = 'NT AUTHORITY\Authenticated Users')
    CREATE LOGIN [NT AUTHORITY\Authenticated Users] FROM WINDOWS

USE [BlackSquare]
IF NOT EXISTS(SELECT * FROM sys.database_principals WHERE name = 'BlackSquareUser')
    CREATE USER [BlackSquareUser] FOR LOGIN [NT AUTHORITY\Authenticated Users]

GRANT SELECT ON [dbo].[Document] To [BlackSquareUser]
GRANT SELECT ON [dbo].[DocumentSet] To [BlackSquareUser]
GRANT SELECT ON [dbo].[DocumentVersion] To [BlackSquareUser]
GRANT SELECT ON [dbo].[EmailRequest] To [BlackSquareUser]
GRANT SELECT ON [dbo].[Review] To [BlackSquareUser]
GRANT SELECT ON [dbo].[Reviewer] To [BlackSquareUser]

GRANT EXECUTE ON [dbo].[AddDocument] To [BlackSquareUser]
GRANT EXECUTE ON [dbo].[AddReview] To [BlackSquareUser]
GRANT EXECUTE ON [dbo].[AddReviewer] To [BlackSquareUser]
GRANT EXECUTE ON [dbo].[AddVersion] To [BlackSquareUser]
GRANT EXECUTE ON [dbo].[CreateNewDocumentSet] To [BlackSquareUser]
GRANT EXECUTE ON [dbo].[SetDocumentActiveBit] To [BlackSquareUser]
GRANT EXECUTE ON [dbo].[SetDocumentSetStatus] To [BlackSquareUser]
GRANT EXECUTE ON [dbo].[UpdateDocumentSet] To [BlackSquareUser]
GRANT EXECUTE ON [dbo].[UpdateVersion] To [BlackSquareUser]

